package com.neusoft.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.neusoft.domain.Cart;
import com.neusoft.domain.vo.CartVo;
import com.neusoft.service.CartService;
import com.neusoft.service.impl.CartServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/CartController")
public class CartController {
    @Autowired
    CartService cartService;

    @DeleteMapping("/removeCart")
    public Integer removeCart(Cart cart) {
        return cartService.removeCart(cart);
    }

    @PutMapping("/updateCart")
    public Integer updateCart(Cart cart) {
        return cartService.updateCart(cart);
    }

    @PostMapping("/saveCart")
    public Integer saveCart(Cart cart) {
        return cartService.saveCart(cart);
    }

    // 检验用户手机号是否存在
    @GetMapping("/listCart")
    public List<CartVo> listCart(Cart cart) {
        return cartService.listCart(cart);
    }

}
